#!/bin/sh 
#Version 0.0.8 
#Put together by Alexander S.T. Ross (abushcrafter) 
#Based on the luncher from: https://www.privacyfoundation.de/wiki/PortableLinuxApps 
#Also based on the luncher from: http://portools.com/apps/iceweasel-portable 

#Works with any mozzila base based app like Firefox,ThunderBird,SongBird,SunBird,Fennec (Firefox Mobile),Seamonkey,etc. 

#The reason for the bit of code, for disabling error output of the $app. Is because if you are for instants using Firefox, some addons like ReadItLater reviles (In a URL) your password and user-name of your ReadItLater account. This info then ends up in the system log: "/tmp/xerrs.log". 

#ChangeLog ---------------------------------------------------------------------- 
#   2010/10/31  Alexander .S.T. Ross (abushcrafter) Email: <http://www.google.com/recaptcha/mailhide/d?k=01uNeUuXxeNm9FA3Zciuoqzw==&c=nVfKeb7kjqZVVIQanqJwEC2DP5zrALkSERTopYvj_pU=> 
#      * 0.0.7: Now finds out what the current version of the Mozilla app is. Thanks to my dad. 
#      * 0.0.7: Now gives you a splash screen telling you that Mozilla app is now closed. 
#      * 0.0.7: Added some Debug/Info echos. 
#      * 0.0.7: Removed Dingo's <http://dokupuppylinux.co.cc/> Puppy Linux font fix as it's fixed in newer versions of Puppy Linux (.E.G. Lupu 5.*.* (Might have not been fixed in first few version?)). 
#      * 0.0.7: Removed nooby mistakes of mine. .E.G. variables being exported, "exec" being used to run the Mozilla app. 

#   2010/11/01  Alexander .S.T. Ross (abushcrafter) Email: <http://www.google.com/recaptcha/mailhide/d?k=01uNeUuXxeNm9FA3Zciuoqzw==&c=nVfKeb7kjqZVVIQanqJwEC2DP5zrALkSERTopYvj_pU=> 
#      * 0.0.8: Fixed all bugs. Now works. 
#      * 0.0.8: Added more echos. 

app="firefox" 

echo "${app}portable:Debug/Info: 0="$0"" 
dir=${0%/*} 
echo "${app}portable:Debug/Info: dir="$dir"" 
if [ "$dir" = "$0" ]; then 
  dir="." 
fi 
HOME=${dir}/Mantra/profile 
cd "$dir/Mantra" 
echo "${app}portable:Debug/Info: Current Dir="`pwd` 

version=`./$app --version |tr , \ | cut --fields=3 --delimiter=\ ` 
echo "Welcome to the Linux version of $app $version in portable mode. Feedback is NOT disabled." 

#START: Part of Dingo's <http://dokupuppylinux.co.cc/> additions to this script. 
if test -d profile ; then 
printf "${app}portable:Debug/Info: Profile Directory already exists!\n" 
else 
mkdir -p profile 
fi 
#END: Part of Dingo's <http://dokupuppylinux.co.cc/> additions to this script. 

#Remove the "#" from the next line to disable error output. 
xterm -e ./$app -no-remote -profile "./profile" $@ #2>/dev/null 

echo "${app}portable:Debug/Info: $app is now closed." 
yaf-splash -text "$app Is Now Closed" -bg green -fg black -timeout 3 -display :0 -margin 2 -bw 0 -font "9x15B" -outline 0 
echo "${app}portable:Debug/Info: ${app}portable is now closed." 
